package com.yangxc.core.sms.config;

import com.yangxc.core.sms.handler.AliSmsTemplate;
import com.yangxc.core.sms.props.AliSmsProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yangxc
 * @version 1.0.0
 * @ClassName SmsAutoConfig.java
 * @Description TODO
 * @createTime 2021年07月05日 17:31:00
 */
@Configuration
@EnableConfigurationProperties(value = AliSmsProperties.class)
public class SmsAutoConfig {

    @Bean
    @ConditionalOnProperty(prefix = AliSmsProperties.prefix, name = "enable", havingValue = "true")
    public AliSmsTemplate aliSmsTemplate(AliSmsProperties aliSmsProperties){
        return new AliSmsTemplate(aliSmsProperties);
    }
}
